package com.bi.onlineEducation.web.controller;

import com.bi.onlineEducation.annotation.WebProcess;
import com.bi.onlineEducation.domain.CoursePathPo;
import com.bi.onlineEducation.service.CoursePathService;
import com.bi.onlineEducation.utils.ResultCode;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author: chenYuTao
 * @Time: 2022/1/6 15:44
 * @Description: 基础数据控制层
 **/
@RestController
@Api(tags = "课程播放源信息控制层", description = "课程播放源信息数据接口")
public class CoursePathController {

    @Resource
    private CoursePathService coursePathService;

    @ApiOperation("查询所有")
    @WebProcess
    @GetMapping(value = "/coursePath/findAll")
    public ResultCode findAll() {
        return ResultCode.success(coursePathService.findAll());
    }

    @ApiOperation("根据id查询课程播放源信息")
    @WebProcess
    @GetMapping(value = "/coursePath/findById")
    public ResultCode findById(@RequestParam("id") Integer id) {
        return ResultCode.success(coursePathService.findById(id));
    }

    @ApiOperation("根据cid查询课程播放源信息")
    @WebProcess
    @GetMapping(value = "/coursePath/findCoursePathPoBycId")
    public ResultCode findCoursePathPoBycId(@RequestParam("cId") Integer cId) {
        return ResultCode.success(coursePathService.findCoursePathPoBycId(cId));
    }

    @ApiOperation("保存信息")
    @WebProcess
    @PostMapping(value = "/coursePath/save")
    public ResultCode save(@RequestBody CoursePathPo coursePathPo) {
        return ResultCode.success(coursePathService.save(coursePathPo));
    }

    @ApiOperation("根据id删除课程播放源信息")
    @WebProcess
    @DeleteMapping(value = "/coursePath/deleteById")
    public ResultCode deleteById(@RequestParam("id") Integer id) {
        return ResultCode.success(coursePathService.deleteById(id));
    }


}